package com.example.springbootmybatis.service;

import com.example.springbootmybatis.mapper.UserMapper;
import com.example.springbootmybatis.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;

/**
 * @title: IndexService
 * @Author Tan
 * @Date: 2021/6/24 22:18
 * @Version 1.0
 */
@Service
public class IndexService {
    @Resource
    private UserMapper userMapper;

    public boolean loginCheck(String name, String password) {
        List<User> userList = userMapper.selectByExample(null);
        Iterator it = userList.iterator();
        while (it.hasNext()) {
            User user = (User) it.next();
            if (user.getUsername().equals(name) && user.getPassword().equals(password)) {
                return true;
            }
        }
        return false;
    }
}
